﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Admin/ViewMasterPage.Master" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    <title>管理员客户端——医生</title>
</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="LeftMenuContent" runat="server">
    <li><a href="/Admin/Index"><span class="glyphicon glyphicon-dashboard"></span>首页</a></li>
    <li class="active"><a href="/Admin/Widgets"><span class="glyphicon glyphicon-th"></span>医生</a></li>
    <li><a href="/Admin/Charts"><span class="glyphicon glyphicon-stats"></span>用户</a></li>
    <li><a href="/Admin/Tables"><span class="glyphicon glyphicon-list-alt"></span>监护数据</a></li>
    <li><a href="/Admin/Forms"><span class="glyphicon glyphicon-pencil"></span>管理员</a></li>
    <li><a href="/Admin/Panels"><span class="glyphicon glyphicon-info-sign"></span>操作记录</a></li>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <div class="col-sm-9 col-sm-offset-3 col-lg-10 col-lg-offset-2 main">
        <div class="row">
            <ol class="breadcrumb">
                <li><a href="#"><span class="glyphicon glyphicon-home"></span></a></li>
                <li class="active">医生</li>
            </ol>
        </div>
        <!--/.row-->

        <div class="row">
            <div class="col-lg-12">
                <h1 class="page-header">医生</h1>
            </div>
        </div>
        <!--/.row-->

        <div class="row">
            <div class="col-lg-12">
                <div class="panel panel-default">
                    <div class="panel-body">
                        <div class="btn-toolbar" role="toolbar" id="toolbar1">
                            <div class="btn-group">
                                <button id="btnAdd" type="button" class="btn btn-default" data-toggle="modal"
                                    <%--data-target="#myModal_Add"--%>>
                                    <span class="glyphicon glyphicon-plus"></span>新增</button>
                                <button id="btnDel" type="button" class="btn btn-default" data-toggle="modal"
                                    <%--data-target="#myModal_Del"--%>>
                                    <span class="glyphicon glyphicon-minus"></span>删除</button>
                                <button id="btnUpdate" type="button" class="btn btn-default" data-toggle="modal"
                                    <%--data-target="#myModal_Update"--%>>
                                    <span class="glyphicon glyphicon-pencil"></span>修改</button>
                            </div>
                        </div>
                        <table id="table" data-toggle="table" data-url="/Admin/Json_Doctor" data-show-refresh="true" data-show-toggle="true" data-show-columns="true" data-search="true"
                            data-toolbar="#toolbar1" data-pagination="true" data-sort-name="name" data-sort-order="desc">

                            <thead>
                                <tr>
                                    <th data-field="state" data-radio="true"></th>
                                    <th data-field="Id" data-with="0" data-visible="false" data-align="center">ID</th>
                                    <th data-field="Name" data-sortable="true" data-align="center">姓名</th>
                                    <th data-field="Old" data-sortable="true" data-align="center">年龄</th>
                                    <th data-field="Sex" data-sortable="true" data-align="center">性别</th>
                                    <th data-field="Email" data-sortable="true" data-align="center">Email</th>
                                    <th data-field="Tel" data-sortable="true" data-align="center">电话</th>
                                </tr>
                            </thead>
                        </table>
                    </div>
                </div>
            </div>
        </div>

        <div class="modal fade" id="myModal_Add" tabindex="-1" role="dialog"
            aria-labelledby="myModalLabel" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close"
                            data-dismiss="modal" aria-hidden="true">
                            &times;
                        </button>
                        <h2 class="modal-title" id="myModalLabel_Add">修改
                        </h2>
                        <form role="form">
                            <div class="form-group">
                                <label>姓名：</label>
                                <input class="form-control" id="Placeholder_Add">
                            </div>
                            <div class="row">
                                <div class="col-xs-4">
                                    <div class="form-group">
                                        <label>科室：</label>
                                        <div class="form-group">
                                            <select class="selectpicker form-control" id="office_Select_Add">
                                                <option>内科</option>
                                                <option>外科</option>
                                                <option>妇产科</option>
                                                <option>儿科</option>
                                            </select>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-xs-4">
                                    <label>年龄：</label>
                                    <input class="form-control" id="old_TxtBox_Add">
                                </div>
                                <div class="col-xs-4">
                                    <label>性别：</label>
                                    <div class="form-group">
                                        <select class="selectpicker form-control" id="sex_Select_Add">
                                            <option>男</option>
                                            <option>女</option>

                                        </select>
                                    </div>
                                </div>

                            </div>
                            <div class="form-group">
                                <label>联系电话：</label>
                                <input class="form-control" id="tel_TxtBox_Add">
                            </div>

                            <div class="form-group">
                                <label>邮箱：</label>
                                <input class="form-control" id="email_TxtBox_Add">
                            </div>

                            <div class="form-group">
                                <label>上传照片</label>
                                <input type="file" style="border: 1px dotted #ccc">
                                <p class="help-block">上传小于1M一寸免冠照片（*.jpg  *.png）</p>
                            </div>

                            <label>被监护者</label>
                            <div class="form-group has-success">
                                <input class="form-control" placeholder="Success">
                            </div>
                            <div class="form-group has-success">
                                <input class="form-control" placeholder="Warning">
                            </div>
                            <div class="form-group has-success">
                                <input class="form-control" placeholder="Error">
                            </div>
                        </form>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default"
                            data-dismiss="modal">
                            关闭
                        </button>
                        <button type="button" class="btn btn-primary" id="dialog_btn_add">
                            提交更改
                        </button>
                    </div>
                </div>
                <!-- /.modal-content -->
            </div>
        </div>

        <div class="modal fade" id="myModal_Update">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close"
                            data-dismiss="modal" aria-hidden="true">
                            &times;
                        </button>
                        <h2 class="modal-title" id="myModalLabel_Update">修改
                        </h2>
                        <form role="form">
                            <div class="form-group">
                                <label>姓名：</label>
                                <input class="form-control" id="Placeholder_Update">
                            </div>
                            <div class="row">
                                <div class="col-xs-4">
                                    <div class="form-group">
                                        <label>科室：</label>
                                        <div class="form-group">
                                            <select class="selectpicker form-control" id="office_Select_Update">
                                                <option>内科</option>
                                                <option>外科</option>
                                                <option>妇产科</option>
                                                <option>儿科</option>
                                            </select>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-xs-4">
                                    <label>年龄：</label>
                                    <input class="form-control" id="old_TxtBox_Update">
                                </div>
                                <div class="col-xs-4">
                                    <label>性别：</label>
                                    <div class="form-group">
                                        <select class="selectpicker form-control" id="sex_Select_Update">
                                            <option>男       </option>
                                            <option>女       </option>

                                        </select>
                                    </div>
                                </div>

                            </div>
                            <div class="form-group">
                                <label>联系电话：</label>
                                <input class="form-control" id="tel_TxtBox_Update">
                            </div>

                            <div class="form-group">
                                <label>邮箱：</label>
                                <input class="form-control" id="email_TxtBox_Update">
                            </div>

                            <div class="form-group">
                                <label>上传照片</label>
                                <input type="file" style="border: 1px dotted #ccc">
                                <p class="help-block">上传小于1M一寸免冠照片（*.jpg  *.png）</p>
                            </div>

                            <label>被监护者</label>
                            <div class="form-group has-success">
                                <input class="form-control" placeholder="1号患者ID">
                            </div>
                            <div class="form-group has-success">
                                <input class="form-control" placeholder="2号患者ID">
                            </div>
                            <div class="form-group has-success">
                                <input class="form-control" placeholder="3号患者ID">
                            </div>
                        </form>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default"
                            data-dismiss="modal">
                            关闭
                        </button>
                        <button type="button" class="btn btn-primary" id="dialog_btn_update">
                            提交更改
                        </button>
                    </div>
                </div>
                <!-- /.modal-content -->
            </div>
            <!-- /.modal -->
        </div>

        <div class="modal fade" id="myModal_Del">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close"
                            data-dismiss="modal" aria-hidden="true">
                            &times;
                        </button>
                        <h2 class="modal-title" id="myModalLabel_Del">删除
                        </h2>
                    </div>
                    <div class="modal-body">
                        是否要删除此条数据
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default"
                            data-dismiss="modal">
                            关闭
                        </button>
                        <button type="button" class="btn btn-primary" id="dialog_btn_del">
                            提交更改
                        </button>
                    </div>
                </div>
                <!-- /.modal-content -->
            </div>
            <!-- /.modal -->
        </div>
    </div>
    <!--/.main-->
</asp:Content>

<asp:Content ID="Content4" ContentPlaceHolderID="JsContent" runat="server">
    <script>
        var $table = $('#table');
        var $button_Update = $('#btnUpdate');
        var $button_Del = $('#btnDel');
        var $button_Add = $('#btnAdd');
        var $MyJson;
        var $office = Array('内科', '外科', '妇产科', '儿科');
        var $tab_Json;
        /**************************************设置*********************************************/
        $(function () {
            $button_Update.click(function () {
                $tab_Json = eval(JSON.stringify($table.bootstrapTable('getSelections')));
                if ($tab_Json[0]) {
                    $.getJSON("/Admin/GetJson", { "id": $tab_Json[0].Id, "class": "doctor" }, function (data) {
                        $('#myModal_Update').modal('show');
                        $('#Placeholder_Update').val(data.Name);
                        $('#old_TxtBox_Update').val(data.Old);
                        $('#sex_Select_Update').val(data.Sex[0]);
                        $('#office_Select_Update').val($office[data.Offices - 3]);
                        $('#tel_TxtBox_Update').val(data.Tel);
                        $('#email_TxtBox_Update').val(data.Email);
                    });
                }
                else {
                    alert("请选择修改项!");
                }
            });
            $('#dialog_btn_update').click(function () {
                $tab_Json = eval(JSON.stringify($table.bootstrapTable('getSelections')));
                $("#myModal_Update").modal('hide');
                $.post("/Admin/SetJson", {
                    "name": $('#Placeholder_Update').val(),
                    "id": $tab_Json[0].Id,
                    "old": $('#old_TxtBox_Update').val(),
                    "sex": $('#sex_Select_Update').val(),
                    "offices": $('#office_Select_Update').val(),
                    "tel": $('#tel_TxtBox_Update').val(),
                    "email": $('#email_TxtBox_Update').val(),
                    "class": "doctor"
                }, function (data) {
                    if (data) {
                        $table.bootstrapTable('load', data);
                        alert("修改成功");
                    }
                    else {
                        alert("修改失败");
                    }
                });
            });
        });

        /***************************************删除*******************************************/
        $(function () {
            $button_Del.click(function () {
                $tab_Json = eval(JSON.stringify($table.bootstrapTable('getSelections')));
                if ($tab_Json[0]) {
                    $('#myModal_Del').modal('show');
                }
                else {
                    alert("请选择删除项!");
                }
            });
            $('#dialog_btn_del').click(function () {
                $tab_Json = eval(JSON.stringify($table.bootstrapTable('getSelections')));
                $("#myModal_Del").modal('hide');
                $.post("/Admin/RemoveJson", {
                    "id": $tab_Json[0].Id,
                    "class": "doctor"
                }, function (data) {
                    if (data) {
                        $table.bootstrapTable('load', data);
                        alert("删除成功");
                    }
                    else {
                        alert("删除失败");
                    }
                });
            });
        });

        /***************************************添加******************************************/
        $(function () {
            $button_Add.click(function () {
                $tab_Json = eval(JSON.stringify($table.bootstrapTable('getSelections')));
                $('#myModal_Add').modal('show');
            });
            $('#dialog_btn_add').click(function () {
                $tab_Json = eval(JSON.stringify($table.bootstrapTable('getSelections')));
                if (($('#Placeholder_Add').val()) && ($('#old_TxtBox_Add').val()) && ($('#sex_Select_Add').val()) && ($('#office_Select_Add').val()) && ($('#tel_TxtBox_Add').val()) && ($('#email_TxtBox_Add').val())) {
                    $("#myModal_Add").modal('hide');
                    $.post("/Admin/AddJson", {
                        "name": $('#Placeholder_Add').val(),
                        "old": $('#old_TxtBox_Add').val(),
                        "sex": $('#sex_Select_Add').val(),
                        "offices": $('#office_Select_Add').val(),
                        "tel": $('#tel_TxtBox_Add').val(),
                        "email": $('#email_TxtBox_Add').val(),
                        "class": "doctor"
                    }, function (data) {
                        if (data) {
                            $table.bootstrapTable('load', data);
                            alert("添加成功");
                        }
                        else {
                            alert("添加失败");
                        }
                    });
                }
                else {
                    alert("请检查未完成项");
                }
            });
        });

    </script>
</asp:Content>
